The existence of intermediate-mass black holes (IMBHs) in globular clusters has been debated. One possible way to form IMBHs in globular clusters is by repeating the merger of BHs in star clusters. However, gravitational-wave recoils kick the IMBHs out from the host globular clusters before they reach 500 Msun. Another way is repeating mergers of main-sequence stars, the so-called runaway collisions. If the density of globular clusters (and any star clusters) is high enough, stars collide and form very massive stars, which are stars typically more massive than 1000 Msun. They can finally collapse to IMBHs. In previous simulations starting from already formed gas-free star clusters, very massive stars easily lost their mass due to the strong stellar wind and left stellar-mass BHs. In the formation phase of star clusters, however, the parental molecular gas can maintain the compactness and high density of the forming star clusters. We developed a new N-body/smoothed particle hydrodynamics code, ASURA+BRIDGE, which can treat the collisions of stars and hydrodynamics of gas at the same time. With this code, we, for the first time, performed globular cluster formation simulations resolving individual stars. In our simulations, runaway collision caused the formation of very massive stars with a maximum mass of 10,000 Musn, which finally collapsed to 3,000--4,000 Msun IMBHs after they lost their mass due to the stellar wind. https://www.science.org/doi/10.1126/science.adi4211